import { FinanceFlowService } from 'services/Api'
import { DateFormat } from 'services/Util'

/* 搜索相关
-------------------------- */
export const listSearchMixin = {
  data () {
    return {
      search: '', // 搜索内容
      payEvent: '',
      startTime: '',
      endTime: ''
    }
  },
  methods: {
    // 搜索条件改变
    searchCondChange (list) {
      this.search = ''
      this.payEvent = ''
      this.startTime = ''
      this.endTime = ''
      list.forEach(i => {
        switch (i.name) {
          case '模糊查询':
            this.search = i.value
            break
          case '用户操作':
            this.payEvent = i.value
            break
          case '注册时间':
            this.startTime = DateFormat(i.value[0], 'yyyy-MM-dd hh:mm:ss') || ''
            this.endTime = DateFormat(i.value[1], 'yyyy-MM-dd hh:mm:ss') || ''
        }
      })
      this.getTableData()
    }
  }
}

export const listExportMixin = {
  computed: {
    // 导出参数
    exportUserPayListParam () {
      return {
        acc_id: this.acc_id,
        page: this.page,
        page_size: this.pageSize,
        sort_field: this.sort_field,
        sort_type: this.sort_type,
        search: this.search,
        pay_event: this.payEvent,
        start_time: this.startTime,
        end_time: this.endTime
      }
    }
  },
  methods: {
    // 导出接口
    currentExportApi () {
      return FinanceFlowService.exportUserPayList(this.exportUserPayListParam)
    }
  }
}
